{extend name="common/main"/}

{block name="body"}
    <div class="main-title">
        <h2>
            [ {$data.alias} ][标识：{$data.name}]
            应用权限菜单管理
        </h2>
    </div>
    <div class="with-padding">
        <div class="margin-bottom">
            {notempty name="list"}
            {volist name="list" id="menu"}
            <a title="新增一级菜单" class="btn btn-bg btn-success" href="{:url('medit',['pid' => $menu['id'],'app'=> $app])}"> + 新增一级菜单 </a>
            <a title="编辑" class="btn btn-bg btn-info" href="{:url('medit',['id' => $menu['id'], 'app'=> $app])}">编辑</a>
            {/volist}
            {else /}
            <a title="新增一级菜单" class="btn btn-bg btn-success" href="{:url('medit',['app'=> $app])}"> + 新增主菜单 </a>
            {/notempty}
        </div>

        <form class="ids module-menu">
            <table class="table table-bordered table-striped muu-table menu-header">
                <thead>
                <tr>
                    <th class="row-selected">
                        <input type="checkbox" class="check-all" id="check-all">
                    <label for="check-all"></label>
                    </th>
                    <th class="hidden">{:lang('ID')}</th>
                    <th width="300">名称</th>
                    <th width="160">分组</th>
                    <th width="400">URL</th>
                    <th>排序</th>
                    <th>是否隐藏</th>
                    <th width="120">操作</th>
                </tr>
                </thead>
            </table>
                
            {notempty name="list"}
            {volist name="list" id="menu"}
            <table class="table table-bordered table-striped table-hover muu-table">
                <tbody>
                    
                    {notempty name="menu._child"}
                    {volist name="menu._child" id="cmenu2"}
                    <tr>
                        <td> 
                            <input class="ids" id="cmenu2-{$menu.id}" type="checkbox" name="id[]" value="{$cmenu2.id}">
                            <label for="cmenu2-{$cmenu2.id}"></label>
                        </td>
                        <td class="hidden">
                            {$cmenu2.id}
                        </td>
                        <td class="top-chile-title">
                            -- <span style="font-weight: 600;">{$cmenu2.title}</span>
                        </td>
                        <td>
                            {$cmenu2.group}
                        </td>
                        <td>
                            {$cmenu2.url}
                        </td>
                        <td>
                            {$cmenu2.sort}
                        </td>
                        <td>
                            {$cmenu2.hide_str}
                        </td>
                        <td class="text-right">
                            <a title="新增" class="btn btn-sm btn-success" href="{:url('medit',['pid' => $cmenu2['id'], 'app'=> $app])}"> + 新增 </a>
                            <a title="编辑" class="btn btn-sm btn-info" href="{:url('medit',['id' => $cmenu2['id'], 'pid'=> $cmenu2['pid'], 'app'=> $app])}">编辑</a>
                            <a title="删除" class="btn btn-sm btn-danger confirm ajax-get" title="删除" href="{:url('mdel',['ids' => $cmenu2['id'], 'app'=> $app])}">删除</a>
                        </td>
                    </tr>
                    {notempty name="cmenu2._child"}
                    {volist name="cmenu2._child" id="cmenu3"}
                    <tr>
                        <td>
                            <input class="ids" id="cmenu3-{$cmenu3.id}" type="checkbox" name="id[]" value="{$cmenu3.id}">
                            <label for="cmenu3-{$cmenu3.id}"></label>
                        </td>
                        <td class="hidden">
                            {$cmenu3.id}
                        </td>
                        <td>
                            -------- {$cmenu3.title}
                        </td>
                        <td>
                            {$cmenu3.group}
                        </td>
                        <td>
                            {$cmenu3.url}
                        </td>
                        <td>
                            {$cmenu3.sort}
                        </td>
                        <td>
                            {$cmenu3.hide_str}
                        </td>
                        <td class="text-right">
                            <a title="编辑" class="btn btn-sm btn-info" href="{:url('medit',['id' => $cmenu3['id'], 'pid' => $cmenu3['pid'], 'app'=> $app])}">编辑</a>
                            <a title="删除" data-role="delete" class="btn btn-sm btn-danger confirm ajax-get" title="删除" href="{:url('mdel',['ids' => $cmenu3['id'],'app'=> $app])}">删除</a>
                        </td>
                    </tr>
                    {/volist}
                    {/notempty}

                    {/volist}
                    {/notempty}
                </tbody>
            </table>
            {/volist}
            {else/}
            <div class="text-center">空空如也~</div>
            {/notempty}
                
        </form>
        <!-- 分页 -->
        <div class="page">

        </div>
    </div>
{/block}

{block name="script"}
    <script type="text/javascript">
        $(function () {
            //搜索功能
            $("#search").click(function () {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function (e) {
                if (e.keyCode === 13) {
                    $("#search").click();
                    return false;
                }
            });
            //导航高亮

            //点击排序
            $('.list_sort').click(function () {
                var url = $(this).attr('url');
                if (url != undefined && url != '') {
                    window.location.href = url;
                }
            });
        });
    </script>
{/block}